package com.heima.freemarker.controller;

import com.heima.freemarker.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class FreemarkerController {

    @GetMapping("/hello")
    public String hello(HttpServletRequest request, Model model){
//        把页面中需要的数据放到request域中
        model.addAttribute("name","zhangsan");
        Student student = new Student("lisi",30);
        model.addAttribute("stu",student);


        List<Student> studentList = new ArrayList<>();

        studentList.add(new Student("小白",20));
        studentList.add(new Student("小红",24));
        studentList.add(new Student("小蓝",26));

        model.addAttribute("stus",studentList);


        Map map = new HashMap();
        map.put("a","AAAA");
        map.put("b","BBBB");
        map.put("c","CCCC");

        model.addAttribute("userMap",map);




        return "basic";
    }


}
